#encoding: utf-8
from rest_framework import serializers
from .models import NewsCategory,News,Comment,Banner
from apps.xfzauth.serializers import UserSerializers

class NewsCategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = NewsCategory
        fields = ['id','name']

class NewsSerializer(serializers.ModelSerializer):
    category = NewsCategorySerializer()
    author = UserSerializers()
    class Meta:
        model = News
        fields = ['id','title','desc','thumbnail','category','author','pub_time']

class CommentSerializer(serializers.ModelSerializer):
    author = UserSerializers
    class Meta:
        model = Comment
        fields = ['id','content','author','pub_time']

class BannerSerializer(serializers.ModelSerializer):
    class Meta:
        model = Banner
        fields = ['id','image_url','link_to','priority']